ExportDocBlock.php
<?php
namespace Tlf\Scrawl\Ext\DefaultExt;
/**
* Export docblock content above `@export(key)`
* @featured
*/
class ExportDocBlock extends \Tlf\Scrawl\ExtensionType\DefaultExt {
protected $regData = [
'key' => '([^\)]*)',
'export.key' => '/\@export\(([^\)]*)\)/',
'WriteExport' => '/((?:.|\n)*) *(\@export.*)/',
];
protected $extensions = [];
public function __construct($scrawl){
parent::__construct($scrawl);
}
public function onSourceFileFound($file){
$content = $file->content();
$ext = $file->ext;
$docBlocks = \Tlf\Scrawl\DocBlock::extractBlocks($content, $ext);
foreach ($docBlocks as $db){
$this->match('WriteExport',$db->clean);
}
}
public function matchWriteExport($info,$comment,$export){
$comment = \Tlf\Scrawl\Utility::trimTextBlock($comment);
$key = $this->match('export.key',$export);
if (!is_array($key))return;
$key = $key[0];
$this->scrawl->addOutput('key', $key, $comment);
}
public function matchExport_Key($full, $key){
return $key;
}
}